.class public Lcom/teewoo/app/bus/manager/collection/StationCollectionManager;
.super Ljava/lang/Object;
.source "StationCollectionManager.java"


# instance fields
.field private dbInstance:Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter "context"

    .prologue
    .line 26
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 27
    new-instance v0, Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;

    invoke-direct {v0, p1}, Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/teewoo/app/bus/manager/collection/StationCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;

    .line 28
    return-void
.end method


# virtual methods
.method public delete(Ljava/lang/Integer;)V
    .locals 4
    .parameter "id"

    .prologue
    .line 56
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/StationCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 57
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "delete from station_collection where _id =?"

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    aput-object p1, v2, v3

    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 58
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 59
    return-void
.end method

.method public deleteAll()V
    .locals 3

    .prologue
    .line 66
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/StationCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 67
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "delete from station_collection"

    const/4 v2, 0x0

    new-array v2, v2, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 68
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 69
    return-void
.end method

.method public findByStationId(Ljava/lang/Integer;)Lcom/teewoo/app/bus/model/collection/StationCollection;
    .locals 8
    .parameter "stationId"

    .prologue
    const/4 v7, 0x1

    const/4 v6, 0x0

    .line 91
    iget-object v3, p0, Lcom/teewoo/app/bus/manager/collection/StationCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;

    invoke-virtual {v3}, Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 92
    .local v1, database:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v2, 0x0

    .line 95
    .local v2, tempSc:Lcom/teewoo/app/bus/model/collection/StationCollection;
    const-string v3, "select * from station_collection where station_id = ?"

    .line 96
    new-array v4, v7, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    aput-object v5, v4, v6

    .line 94
    invoke-virtual {v1, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 97
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v3

    if-eqz v3, :cond_0

    .line 98
    new-instance v2, Lcom/teewoo/app/bus/model/collection/StationCollection;

    .end local v2           #tempSc:Lcom/teewoo/app/bus/model/collection/StationCollection;
    invoke-interface {v0, v6}, Landroid/database/Cursor;->getInt(I)I

    move-result v3

    invoke-static {v3}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v3

    invoke-interface {v0, v7}, Landroid/database/Cursor;->getInt(I)I

    move-result v4

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v4

    .line 99
    const/4 v5, 0x2

    invoke-interface {v0, v5}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v5

    const/4 v6, 0x3

    invoke-interface {v0, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    .line 98
    invoke-direct {v2, v3, v4, v5, v6}, Lcom/teewoo/app/bus/model/collection/StationCollection;-><init>(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;)V

    .line 108
    .restart local v2       #tempSc:Lcom/teewoo/app/bus/model/collection/StationCollection;
    :cond_0
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 109
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 110
    return-object v2
.end method

.method public getScrollData(II)Ljava/util/List;
    .locals 11
    .parameter "startResult"
    .parameter "maxResult"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(II)",
            "Ljava/util/List",
            "<",
            "Lcom/teewoo/app/bus/model/collection/StationCollection;",
            ">;"
        }
    .end annotation

    .prologue
    const/4 v10, 0x2

    const/4 v9, 0x1

    const/4 v8, 0x0

    .line 121
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V

    .line 122
    .local v2, list:Ljava/util/List;,"Ljava/util/List<Lcom/teewoo/app/bus/model/collection/StationCollection;>;"
    iget-object v3, p0, Lcom/teewoo/app/bus/manager/collection/StationCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;

    invoke-virtual {v3}, Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 124
    .local v1, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v3, "SELECT * FROM station_collection ORDER BY save_time DESC limit ?,?"

    .line 125
    new-array v4, v10, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v5

    aput-object v5, v4, v8

    invoke-static {p2}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v5

    aput-object v5, v4, v9

    .line 123
    invoke-virtual {v1, v3, v4}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v0

    .line 127
    .local v0, cursor:Landroid/database/Cursor;
    invoke-interface {v0}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v3

    if-eqz v3, :cond_1

    .line 129
    :cond_0
    new-instance v3, Lcom/teewoo/app/bus/model/collection/StationCollection;

    invoke-interface {v0, v8}, Landroid/database/Cursor;->getInt(I)I

    move-result v4

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v4

    invoke-interface {v0, v9}, Landroid/database/Cursor;->getInt(I)I

    move-result v5

    invoke-static {v5}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v5

    .line 130
    invoke-interface {v0, v10}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    const/4 v7, 0x3

    invoke-interface {v0, v7}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v7

    invoke-direct {v3, v4, v5, v6, v7}, Lcom/teewoo/app/bus/model/collection/StationCollection;-><init>(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;)V

    .line 129
    invoke-interface {v2, v3}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 131
    invoke-interface {v0}, Landroid/database/Cursor;->moveToNext()Z

    move-result v3

    .line 128
    if-nez v3, :cond_0

    .line 134
    :cond_1
    invoke-interface {v0}, Landroid/database/Cursor;->close()V

    .line 135
    invoke-virtual {v1}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 137
    return-object v2
.end method

.method public save(Lcom/teewoo/app/bus/model/collection/StationCollection;)V
    .locals 5
    .parameter "staCol"

    .prologue
    .line 36
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/StationCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 45
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "insert into station_collection(station_id, station_name, save_time) values (?, ?, ?);"

    .line 46
    const/4 v2, 0x3

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/StationCollection;->getStationId()Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x1

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/StationCollection;->getStationName()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x2

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/StationCollection;->getSaveTime()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    .line 45
    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 47
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 48
    return-void
.end method

.method public update(Lcom/teewoo/app/bus/model/collection/StationCollection;)V
    .locals 5
    .parameter "staCol"

    .prologue
    .line 77
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/StationCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/StationCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 78
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "update station_collection set station_id = ?, station_name = ?, save_time = ? where _id=?"

    .line 79
    const/4 v2, 0x3

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/StationCollection;->getStationId()Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x1

    .line 80
    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/StationCollection;->getStationName()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x2

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/StationCollection;->getSaveTime()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    .line 78
    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 81
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 82
    return-void
.end method
